//personnel
(function(){
    var indextype =[
        {"value":1,"text":"全文"},
        {"value":2,"text":"姓名"},
        {"value":3,"text":"意向岗位"}
    ]
//indextype.option.unshift({"value":8,"text":"请选","selected":true})
    $("#resumeSearch #keyword_type").select({
        optionData:indextype,
        css:'personOptions',//下拉层的css
        //selectWidth: 300,//菜单按扭的宽
        //selectHeight: 80,//菜单按扭的高
        offset:Array(0,1)
    });

    siteArea.unshift({"value":'',"text":"地区不限","selected":true});
    $("#resumeSearch #selArea").select({
        optionData:siteArea,
        css:'personOptions',//下拉层的css
        //selectWidth: 300,//菜单按扭的宽
        //selectHeight: 80,//菜单按扭的高
        offset:Array(0,1)
    });

    var sex = [
        {"value":0,"text":"性别不限"},
        {"value":1,"text":"男"},
        {"value":2,"text":"女"}
    ]
    var select1 = $("#sex ").select({
        optionData:sex,//菜单选项数据
        callback:function(val,text){
            person_jump(sex_url,'sex',val);
        }//选择后的动作
    });

    option_education.unshift({"text": "学历不限", "value": 0});
    var select2 = $("#education ").select({
        optionData:option_education,//菜单选项数据
        callback:function(val,text){
            person_jump(education_url,'education',val);
        }//选择后的动作
    });

    var homeaddress = areaForHomeAddress;

    var select3 = $("#homeaddress").select({
        optionData:homeaddress,//菜单选项数据
        callback:function(val,text){
            person_jump(homeaddress_url,'homeaddress',val);
        }//选择后的动作
    });

    var households = areaForHouseHolds;

    var select4 = $("#census").select({
        optionData:households,//菜单选项数据
        callback:function(val,text){
            person_jump(census_url,'census',val);
        }//选择后的动作
    });

    var sortdesc = [
        {"value":0,"text":"智能排序"},
        {"value":1,"text":"时间排序"}
    ];

    var select5 = $("#sortdesc").select({
        optionData:sortdesc,//菜单选项数据
        callback:function(val,text){
            person_jump(sortdesc_url,'sortdesc',val);
        }//选择后的动作
    });

    function person_jump(linkurl,define_link,val){
        var exl="?";
        if(linkurl.indexOf("?") > 0 ){
            exl='&';
        }
        location.href=linkurl+exl+define_link+'='+val;
    }

    //checkbox  点击事件
    function boxoption(othis,url,name,val){
        var exl="?";
        if(url.indexOf("?") > 0 ){
            exl='&';
        }

        if($(othis).attr('checked')=='checked'){
            location.href=url+exl+name+'='+val;
        }else{
            location.href=url+exl;
        }
    }

    $("#havedetails").click(function(){
        boxoption(this,havedetails_url,'havedetails','9');
    })
    $("#chkphoto_open").click(function(){
        boxoption(this,chkphoto_open_url,'chkphoto_open','1');
    })
    $("#haveworkexp").click(function(){
        boxoption(this,haveworkexp_url,'haveworkexp','1');
    })

    //简历checkbox全选
    $('#allcheckbox').click(function(){
        if($(this).attr('checked')=='checked'){
            $('#list_content').find("[type='checkbox']").attr("checked",'true');//全选


        }else{
            $('#list_content').find("[type='checkbox']").removeAttr("checked");//取消全选
        }
    });

    $("#list_content").find("[type='checkbox']").click(function() {//单选
        curren_id = $(this).attr('id');
        curren_checked = $(this).attr('checked');
        curren_value = $(this).val();

        var str = "";
        if (curren_checked == 'checked') {
            $(this).attr("checked", 'true');
        } else {
            $(this).removeAttr("checked");
        }
    });
    //提交简历组按钮
    $("#browse_resumes").click(function(){
        var str = "";
        //生成链接地址
        var all_length = $("#list_content").find("[type='checkbox'][checked]").length;
        i = 1;
        $("#list_content").find("[type='checkbox'][checked]").each(function () {
            if(i == 1){
                first_uid = $(this).val();
            }
            if(i==all_length){
                str += $(this).val();
            }else{
                str += $(this).val()+",";
            }
            i++;
        })
        if(str!=''){
            window.open("/resume_"+first_uid+".html?suid="+str);
        }
    });

})(jQuery);